home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Skunkware 5
/
Skunkware 5.iso
/
src
/
X11
/
xsw
/
condis.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-07-04
|
67KB
|
2,628 lines
/***************************************************************************
*
* Copyright (c) 1990-1993 The Santa Cruz Operation, Inc.
*
* All rights reserved. No part of this program or publication may be
* reproduced, transmitted, transcribed, stored in a retrieval system,
* or translated into any language or computer language, in any form or
* by any means, electronic, mechanical, magnetic, optical, chemical,
* biological, or otherwise, without the prior written permission of:
*
* The Santa Cruz Operation , Inc. (408) 425-7222
* 400 Encinal St., Santa Cruz, California 95060 USA
*
**************************************************************************/
/*
* SCCS Stuff
*
* @(#) condis.c 12.1 95/07/05 SCOINC
*
* S002, 24-Oct-93, rickra
* Added 32v5 streams stuff..
*
* S001, 15-Sep-93, rickra
* Added command line capabilities.
* Replaced all read and writes with xsw_read and xsw_writes....
* Added disk space stuf..
*
* S000, 25-May-93, rickra
* Added copyright and modification history
*/
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/Protocols.h>
#include <Xm/SelectioB.h>
#include <Xm/DialogS.h>
#include <Xm/MessageB.h>
#include <Xm/Form.h>
#include <Xm/Text.h>
#include <Xm/Label.h>
#include <X11/StringDefs.h>
#include "include/unixincs.h"
#include "include/resources.h"
#include "include/buttons.h"
#include "include/xswboth.h"
#include "include/xsw.h"
#include "include/sync.h"
#include "include/sepwin.h"
extern struct NetworkXswStruct *current_server;
extern struct NetworkXswStruct *head_server;
extern struct NetworkXswStruct *selected_server;
extern int server_count;
extern XmString *server_list;
extern Widget swindow;
extern int FileDescriptor;
extern Widget TOGGLE_BUTTONS_WIDGETS[Max_state_buttons];
extern int configured_port;
extern Widget sub_menu_state_list[Max_sub_menu_buttons];
extern MyResources res;
extern int inCommandLineOptionParse;
extern int current_font;
#define MAX_SERVERS 50
char *copyselectedItems[MAX_SERVERS];
int *copyselectedItemsPos[MAX_SERVERS];
struct utsname sysuts;
int uname_size = 0;
char *client_name = NULL;
int got_permission = 0;
int get_host_result = 0;
Widget disconnect_dialog;
Widget disconnect_scrolled_list;
Widget disconnect_ok_button;
Widget disconnect_cancel_button;
Widget connect_server_text_widget;
Widget port_text_widget;
int disconnect_selected_num = 0;
XmString *server_list;
struct hostent *RemoteHostInfo;
struct sockaddr_in SocketID;
void
destroy_callback (Widget my_widget, DestroyCallbackClientData client_data,
XmAnyCallbackStruct cbs);
void
expose_callback (Widget widget,
struct expose_callback_struct *client_data,
XmDrawingAreaCallbackStruct * call_data);
void
input_callback (Widget widget,
struct NetworkXswStruct *client_data,
XmDrawingAreaCallbackStruct * call_data);
void
bad_host (w, client_data, call_data)
Widget w;
caddr_t client_data;
XmAnyCallbackStruct *call_data;
{
get_host_result = 0;
}
GetHost (host_name)
char *host_name;
{
Arg args[2];
int argcount;
XmString message;
Widget dialog;
RemoteHostInfo = gethostbyname (host_name);
if (RemoteHostInfo == NULL)
{
message = XmStringCreateSimple ("Host name lookup failure");
argcount = 0;
XtSetArg (args[argcount], XmNmessageString, message);
argcount++;
dialog = XmCreateMessageDialog (toplevel, "message", args, argcount);
XmStringFree (message);
XtAddCallback (dialog, XmNokCallback, bad_host, NULL);
XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
XtManageChild (dialog);
get_host_result = 0;
}
else
get_host_result = 1;
}
/***********************************************************************
Connection()
Here is where the client establishes a connection with the
server. In order to do that, we must load the server's info
info the SocketID structure. We need 1) The address of the
remote host (in network byte order) and 2) the port that we
will bind to on the remote side. So in order to do this, we
must have a specific port in mind to go to. In other words we
must have predetermined a port that we are going to use for the
client/server network connection.
***********************************************************************/
int
Connection ()
{
int port;
struct servent *ServiceNum;
/*
int optlen, maxseg, sendbuff, recievebuff, no_delay;
*/
/*
* getservbyname only returns a null pointer on error
*/
port = htons (configured_port);
/*
* optlen = sizeof(no_delay); no_delay = 1;
* setsockopt(current_server->FileDescriptor,IPPROTO_TCP,TCP_NODELAY, (char
* *)&no_delay,sizeof(no_delay));
*
* recievebuff = 100000; sendbuff = 100000;
*
* setsockopt(current_server->FileDescriptor,SOL_SOCKET,SO_RCVBUF,
* &recievebuff,sizeof(recievebuff));
*
* setsockopt(current_server->FileDescriptor,SOL_SOCKET,SO_SNDBUF,
* &sendbuff,sizeof(int));
*/
bzero (&SocketID, sizeof (struct sockaddr_in));
/*
* This value is ALWAYS the same
*/
/*
fprintf(stdout,"Official host name = %s\n",RemoteHostInfo -> h_name);
fprintf(stdout,"h_addr = %s\n",RemoteHostInfo -> h_addr_list[0]);
fprintf(stdout,"Host address type = %d\n",RemoteHostInfo -> h_addrtype);
fprintf(stdout,"Alias name = %s\n",RemoteHostInfo -> h_aliases);
*/
SocketID.sin_family = AF_INET;
bcopy (RemoteHostInfo -> h_addr,
&SocketID.sin_addr,
RemoteHostInfo -> h_length);
/*
fprintf(stdout,"Trying %s....\n",inet_ntoa(SocketID.sin_addr));
*/
/*
* Bind to a specific port The port must be in network byte order
*/
SocketID.sin_port = port;
/*
* Get a TCP socket
*/
FileDescriptor = socket (AF_INET, SOCKTYPE, 0); /* auto configure */
if (FileDescriptor == -1)
{
perror ("Error Creating Socket");
printf ("Error Number was: %d\n", errno);
#ifdef TESTING
gct_writelog ("xswLOG");
#endif
exit (1);
}
if (connect (FileDescriptor, &SocketID, sizeof (struct sockaddr_in)) < 0)
{
/*
fprintf(stdout,"Error from connect, error num = %d\n",errno);
*/
return (0);
}
return (1);
} /* end of Connection */
advise_user_of_broken_connection (server_pointer)
struct NetworkXswStruct *server_pointer;
{
char broken_server_message[256];
XmString message;
Widget dialog;
Arg args[5];
int argcount;
sprintf (broken_server_message, "Lost Connection to %s",
server_pointer -> server_name);
message = XmStringCreateSimple (broken_server_message);
argcount = 0;
XtSetArg (args[argcount], XmNmessageString, message);
argcount++;
dialog = XmCreateMessageDialog (toplevel, "message", args, argcount);
XmStringFree (message);
XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
XtManageChild (dialog);
}
remove_server_from_linked_list (server_pointer)
struct NetworkXswStruct *server_pointer;
{
if (server_pointer == head_server)
{
head_server = server_pointer -> forward_link;
/*
* Might be no more in the list....
*/
if (head_server != NULL)
head_server -> backward_link = NULL;
}
else
{
server_pointer -> backward_link -> forward_link =
server_pointer -> forward_link;
/*
* Might be the last one in the list.....
*/
if (server_pointer -> forward_link != NULL)
server_pointer -> forward_link -> backward_link =
server_pointer -> backward_link;
}
}
remove_server_callbacks (server_pointer)
struct NetworkXswStruct *server_pointer;
{
int j;
for (j = 0; j < server_pointer -> current_items; j++)
{
XtRemoveCallback (server_pointer ->
SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].DrawAreaW,
XmNresizeCallback, expose_callback,
server_pointer);
XtRemoveCallback (server_pointer ->
SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].DrawAreaW,
XmNexposeCallback, expose_callback,
server_pointer);
XtRemoveCallback (server_pointer ->
SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].DrawAreaW,
XmNinputCallback, input_callback,
server_pointer);
/*
* Should also remove color help callbacks, but it would mean keeping track
* of the client data......
*/
/*
* Also need to remove WMProtocolCallback and free up the client
* data.....!!
*/
XmRemoveWMProtocolCallback (
server_pointer -> SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].shell_widget,
server_pointer -> SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].destroy_client_data_pointer ->
WM_DELETE_WINDOW, destroy_callback,
(caddr_t) server_pointer -> SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].destroy_client_data_pointer
);
free (server_pointer ->
SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].destroy_client_data_pointer);
}
}
destroy_server_windows (server_pointer)
struct NetworkXswStruct *server_pointer;
{
int j;
for (j = 0; j < server_pointer -> current_items; j++)
{
#ifdef OLD_WAY
XtPopdown (
server_pointer -> SEPERATE_WINDOWS_LIST[
server_pointer -> DISPLAY_LIST[j].button_num].shell_widget);
#endif
XtDestroyWidget (
server_pointer -> SEPERATE_WINDOWS_LIST[
server_pointer -> DISPLAY_LIST[j].button_num].shell_widget);
}
}
free_server_memory (server_pointer)
struct NetworkXswStruct *server_pointer;
{
int j;
for (j = 0; j < CPU_AVG_MAX; j++)
{
free (server_pointer -> cpu_avg[j]);
}
for (j = 0; j < CPU_AVG_MAX; j++)
{
free (server_pointer -> wait_avg[j]);
}
free (server_pointer -> mynmblock);
free (server_pointer -> procs);
free (server_pointer -> oldprocs);
free (server_pointer -> poldprocs);
free (server_pointer -> pprocs);
free (server_pointer -> my_sysinfo);
free (server_pointer -> my_sysinfo_last);
free (server_pointer -> my_minfo);
free (server_pointer -> my_minfo_last);
free (server_pointer -> my_maxmem);
free (server_pointer -> my_freemem);
free (server_pointer -> my_availsmem);
free (server_pointer -> my_v);
free (server_pointer -> my_tune);
free (server_pointer -> mystreams);
if ( server_pointer -> heap_memory_pointer != NULL )
free (server_pointer -> heap_memory_pointer);
free (server_pointer -> memory_pointer_bak);
free (server_pointer -> ps_mem_sort_mode);
free (server_pointer -> disk_space_sort_mode);
/*
* Free up the pixmap.......
*/
for (j = 0; j < server_pointer -> current_items; j++)
XFreePixmap (
server_pointer -> SEPERATE_WINDOWS_LIST[
server_pointer -> DISPLAY_LIST[j].button_num].display,
server_pointer -> SEPERATE_WINDOWS_LIST[
server_pointer -> DISPLAY_LIST[j].button_num].pixmap);
/*
* Free up the widget list for PS MEM
*/
for (j = 0; j < server_pointer -> current_items; j++)
{
if (server_pointer -> DISPLAY_LIST[j].button_num == BUTTON_ps_mem)
{
free (server_pointer ->
SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].screen_widget_list);
free (server_pointer ->
SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].toggle_widget);
free (server_pointer ->
SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].screen_widget_list);
free (server_pointer ->
SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].view_current_sort_widget);
free (server_pointer ->
SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].view_sort_mode);
}
server_pointer ->
SEPERATE_WINDOWS_LIST[server_pointer ->
DISPLAY_LIST[j].button_num].class_name;
}
}
int
create_new_server_list (current_server)
struct NetworkXswStruct *current_server;
{
int j;
Arg args[5];
int argcount;
struct NetworkXswStruct *temp_server_pointer = NULL;
int current_server_position = 0;
if (server_list != NULL)
XtFree (server_list);
server_list = (XmString *) XtMalloc (sizeof (XmString) * server_count);
temp_server_pointer = head_server;
for (j = 0; j < server_count; j++)
{
if (temp_server_pointer == current_server)
current_server_position = j + 1;
server_list[j] = XmStringCreate (temp_server_pointer -> server_name,
XmSTRING_DEFAULT_CHARSET);
temp_server_pointer = temp_server_pointer -> forward_link;
}
argcount = 0;
XtSetArg (args[argcount], XmNitems, server_list);
argcount++;
XtSetArg (args[argcount], XmNitemCount, server_count);
argcount++;
XtSetValues (swindow, args, argcount);
XmListDeselectAllItems (swindow);
return (current_server_position);
}
struct NetworkXswStruct *
activate_new_current_server (server_pointer,
current_server,
current_server_position)
struct NetworkXswStruct *server_pointer;
struct NetworkXswStruct *current_server;
int current_server_position;
{
int i;
Arg args[5];
int argcount;
if (server_pointer == current_server)
{
XmListSelectPos (swindow, 1, False);
current_server = head_server;
/*
* If there is a server, Update the button states, actual, target and message
* fields.....
*/
if (current_server != NULL)
{
for (i = 0; i < Max_state_buttons; i++)
{
argcount = 0;
if (current_server -> TOGGLE_BUTTONS_STATE[i] == 1)
XtSetArg (args[argcount], XmNset, True);
else
XtSetArg (args[argcount], XmNset, False);
argcount++;
XtSetValues (TOGGLE_BUTTONS_WIDGETS[i], args, argcount);
}
display_network_msg (current_server, current_server -> message);
update_StatPeriod (current_server);
update_StatCycle (current_server);
update_Users (current_server);
}
else
{
display_network_msg (NULL, "");
clear_StatPeriod ();
clear_StatCycle ();
clear_Users ();
for (i = 0; i < Max_state_buttons; i++)
toggle_button_reset (NULL, i, NULL);
}
}
else
{
XmListSelectPos (swindow, current_server_position, False);
}
selected_server = current_server;
return (current_server);
}
void
multi_select_disconnect (w, client_data, call_data)
Widget w;
caddr_t *client_data;
XmListCallbackStruct *call_data;
{
XmString *selectedItems;
int *selectedItemPos;
int num_selected = 0;
int i;
selectedItemPos = call_data -> selected_item_positions;
selectedItems = call_data -> selected_items;
num_selected = call_data -> selected_item_count;
/* Copy data before it gets wiped out by X */
for (i = 0; i < num_selected; i++)
{
copyselectedItems[i] = (char *) cs_to_rs (selectedItems[i]);
copyselectedItemsPos[i] = (int *) selectedItemPos[i];
}
disconnect_selected_num = num_selected;
}
void
disconnect_destroy (w, client_data, cbs)
Widget w;
caddr_t *client_data;
XmListCallbackStruct *cbs;
{
XtDestroyWidget (disconnect_dialog);
disconnect_selected_num = 0;
}
void
remove_servers (w, client_data, cbs)
Widget w;
caddr_t *client_data;
XmSelectionBoxCallbackStruct *cbs;
{
struct NetworkXswStruct *server_pointer = NULL;
struct NetworkXswStruct *temp_server_pointer = NULL;
int temp_data;
int i;
int k;
int j;
int current_server_position = 0;
int servers_found = 0;
Arg args[5];
int argcount;
if (disconnect_selected_num > 0)
{
argcount = 0;
XtSetArg (args[argcount], XmNset, False);
argcount++;
XtSetValues (sub_menu_state_list[first_font_button +
current_server -> current_font],
args,
argcount);
#ifdef DEBUG_SERVER
for (k = 0; k < disconnect_selected_num; k++)
{
fprintf (stdout, "position %d \n", copyselectedItemsPos[k]);
}
#endif
for (k = 0; k < disconnect_selected_num; k++)
{
server_pointer = head_server;
#ifdef DEBUG_SERVER
fprintf (stdout, "Here we go\n");
#endif
/*
* Increment server_pointer to the proper position.....
*/
for (i = 1; i < ((int) copyselectedItemsPos[k]) - k; i++)
{
#ifdef DEBUG_SERVER
fprintf (stdout, "Moving to next server %d %d %d\n", copyselectedItemsPos[k], k, ((int) copyselectedItemsPos[k]) - k);
#endif
server_pointer = server_pointer -> forward_link;
}
xsw_write (server_pointer,
server_pointer -> FileDescriptor,
send_quitting_data,
sizeof (int));
/*
* close the socket.....
*/
close (server_pointer -> FileDescriptor);
remove_server_from_linked_list (server_pointer);
remove_server_callbacks (server_pointer);
XtRemoveTimeOut (server_pointer -> timer_id);
destroy_server_windows (server_pointer);
free_server_memory (server_pointer);
/*
* Remove from list...
*/
server_count--;
}
current_server_position = create_new_server_list (server_pointer);
current_server = activate_new_current_server (server_pointer,
current_server,
current_server_position);
free (server_pointer);
argcount = 0;
XtSetArg (args[argcount], XmNlistItems, server_list);
argcount++;
XtSetArg (args[argcount], XmNlistItemCount, server_count);
argcount++;
XtSetValues (disconnect_dialog, args, argcount);
}
/*
* Turn on the correct font button....
*/
if (current_server != NULL)
{
argcount = 0;
XtSetArg (args[argcount], XmNset, True);
argcount++;
XtSetValues (sub_menu_state_list[first_font_button +
current_server -> current_font],
args,
argcount);
current_font = current_server -> current_font;
}
else
{
argcount = 0;
XtSetArg (args[argcount], XmNset, True);
argcount++;
XtSetValues (sub_menu_state_list[first_font_button],
args,
argcount);
current_font = 0;
}
XtDestroyWidget (disconnect_dialog);
disconnect_selected_num = 0;
}
struct NetworkXswStruct *
insert_server (server_name)
char *server_name;
{
struct NetworkXswStruct *new_server = NULL;
struct NetworkXswStruct *viewing_server = NULL;
int not_done = 1;
int i;
Arg args[5];
int argcount;
server_count++;
new_server =
(struct NetworkXswStruct *) calloc (1, sizeof (struct NetworkXswStruct));
new_server -> forward_link = NULL;
new_server -> backward_link = NULL;
new_server -> server_name = server_name;
if (head_server == NULL)
{
head_server = new_server;
}
else
{
viewing_server = head_server;
while (not_done)
{
/* Determne where to insert the server, alphabetically..... */
if (strcmp (new_server -> server_name, viewing_server -> server_name) < 0)
{
/* Check to see if we insert at the VERY beginning... */
if (viewing_server = head_server)
{
head_server = new_server;
new_server -> forward_link = viewing_server;
viewing_server -> backward_link = new_server;
not_done = 0;
}
else
{
/* Attach new server */
new_server -> forward_link = viewing_server;
new_server -> backward_link = viewing_server -> backward_link;
/* Now, re-attach links properly */
new_server -> backward_link -> forward_link = new_server;
new_server -> forward_link -> backward_link = new_server;
not_done = 0;
}
}
else
{
/* check to see if we are at the end of the linked list */
if (viewing_server -> forward_link == NULL)
{
/* attach to end then.... */
new_server -> backward_link = viewing_server;
viewing_server -> forward_link = new_server;
not_done = 0;
}
else
{
/* Go to next server */
viewing_server = viewing_server -> forward_link;
}
}
} /* while (not_done) */
} /* head_server != NULL */
viewing_server = head_server;
return (new_server);
}
initialize_new_server (new_server)
struct NetworkXswStruct *new_server;
{
#define INT_FHEIGHT (new_server->test_fonts->ascent + new_server->test_fonts->descent)
#define INT_FWIDTH (new_server->test_fonts->min_bounds.width)
int i;
/*
* Neet to initialize fonts before we use font information for initialization
* purposes....
*/
init_MyFonts (new_server);
new_server -> current_font = 0;
new_server -> have_res_font = 0;
new_server -> font_change = 0;
for (i = 0; i < Max_state_buttons; i++)
{
new_server -> SEPERATE_WINDOWS_LIST[i].already_created = 0;
new_server -> COMMAND_LIST[i].on = 0;
new_server -> SEPERATE_WINDOWS_LIST[i].max_height = 0;
new_server -> SEPERATE_WINDOWS_LIST[i].max_width = 0;
new_server -> SEPERATE_WINDOWS_LIST[i].min_height = 0;
new_server -> SEPERATE_WINDOWS_LIST[i].min_width = 0;
new_server -> SEPERATE_WINDOWS_LIST[i].pixmap_cur_height = 0;
new_server -> SEPERATE_WINDOWS_LIST[i].pixmap_cur_height = 0;
new_server -> SEPERATE_WINDOWS_LIST[i].x1 = 0;
new_server -> SEPERATE_WINDOWS_LIST[i].y1 = 0;
switch (i)
{
case BUTTON_cpu:
case BUTTON_wait:
case BUTTON_mem:
new_server -> COMMAND_LIST[i].Y_mult = 4;
new_server -> SEPERATE_WINDOWS_LIST[i].Y_mult = 4;
new_server -> SEPERATE_WINDOWS_LIST[i].window_type = DRAWING_WINDOW;
new_server -> SEPERATE_WINDOWS_LIST[i].width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].max_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].max_width =
DisplayWidth (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].min_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].min_width = (INT_FWIDTH * 29);
break;
case BUTTON_other:
new_server -> COMMAND_LIST[i].Y_mult = 8;
new_server -> SEPERATE_WINDOWS_LIST[i].Y_mult = 8;
new_server -> SEPERATE_WINDOWS_LIST[i].window_type = DRAWING_WINDOW;
new_server -> SEPERATE_WINDOWS_LIST[i].width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].max_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].max_width =
DisplayWidth (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].min_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].min_width = (INT_FWIDTH * 29);
break;
case BUTTON_cache:
new_server -> COMMAND_LIST[i].Y_mult = 3;
new_server -> SEPERATE_WINDOWS_LIST[i].Y_mult = 3;
new_server -> SEPERATE_WINDOWS_LIST[i].window_type = DRAWING_WINDOW;
new_server -> SEPERATE_WINDOWS_LIST[i].width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].max_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].max_width =
DisplayWidth (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].min_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].min_width = (INT_FWIDTH * 29);
break;
case BUTTON_dev_stats:
new_server -> COMMAND_LIST[i].Y_mult = 1;
new_server -> SEPERATE_WINDOWS_LIST[i].Y_mult = 1;
new_server -> SEPERATE_WINDOWS_LIST[i].window_type = DRAWING_WINDOW;
new_server -> SEPERATE_WINDOWS_LIST[i].width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[i].draw_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[i].max_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].max_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].min_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].min_width =
(INT_FWIDTH * 80);
break;
case BUTTON_streams:
case BUTTON_sysinfo:
new_server -> SEPERATE_WINDOWS_LIST[i].window_type = DRAWING_WINDOW;
new_server -> COMMAND_LIST[i].Y_mult = 15;
new_server -> SEPERATE_WINDOWS_LIST[i].Y_mult = 15;
new_server -> SEPERATE_WINDOWS_LIST[i].width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[i].draw_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[i].max_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].max_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].min_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].min_width =
(INT_FWIDTH * 80);
break;
case BUTTON_tune_var:
new_server -> SEPERATE_WINDOWS_LIST[i].window_type = DRAWING_WINDOW;
new_server -> COMMAND_LIST[i].Y_mult = 15;
new_server -> SEPERATE_WINDOWS_LIST[i].Y_mult = 15;
new_server -> SEPERATE_WINDOWS_LIST[i].width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[i].draw_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[i].max_height =
DisplayHeight (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].max_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].min_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].min_width =
(INT_FWIDTH * 80);
break;
case BUTTON_ps_cpu:
case BUTTON_ps_io:
case BUTTON_disk_space:
new_server -> COMMAND_LIST[i].Y_mult = 10;
new_server -> SEPERATE_WINDOWS_LIST[i].Y_mult = (DisplayHeight (display, screen) / INT_FHEIGHT) / 2;
new_server -> SEPERATE_WINDOWS_LIST[i].window_type = DRAWING_WINDOW;
new_server -> SEPERATE_WINDOWS_LIST[i].view_current_sort_widget =
(Widget *) calloc (1, sizeof (Widget));
new_server -> SEPERATE_WINDOWS_LIST[i].menu_bar = 0;
if ( i == BUTTON_disk_space )
new_server -> SEPERATE_WINDOWS_LIST[i].width = (INT_FWIDTH * 105);
else
new_server -> SEPERATE_WINDOWS_LIST[i].width = (INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].height =
INT_FHEIGHT * 15;
new_server -> SEPERATE_WINDOWS_LIST[i].draw_width =
DisplayWidth (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_height =
DisplayHeight (display, screen) / 2;
new_server -> SEPERATE_WINDOWS_LIST[i].max_height =
DisplayHeight (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].max_width =
DisplayWidth (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].min_height =
(INT_FHEIGHT * 2);
if ( i == BUTTON_disk_space )
new_server -> SEPERATE_WINDOWS_LIST[i].min_width = 0;
/*
(INT_FWIDTH * 80);
*/
else
new_server -> SEPERATE_WINDOWS_LIST[i].min_width = 0;
/*
(INT_FWIDTH * 80);
*/
break;
case BUTTON_ps_mem:
new_server -> COMMAND_LIST[i].Y_mult = 10;
new_server -> SEPERATE_WINDOWS_LIST[i].Y_mult = (DisplayHeight (display, screen) / INT_FHEIGHT) / 2;
new_server -> SEPERATE_WINDOWS_LIST[i].window_type = DRAWING_WINDOW;
new_server -> SEPERATE_WINDOWS_LIST[i].view_current_sort_widget =
(Widget *) calloc (XtNumber (ps_mem_screens), sizeof (Widget));
new_server -> SEPERATE_WINDOWS_LIST[i].menu_bar = 0;
new_server -> SEPERATE_WINDOWS_LIST[i].width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].height =
INT_FHEIGHT * 15;
/*
(FHEIGHT * current_server -> max_slots_in_use) +
(FHEIGHT * 10);
*/
new_server -> SEPERATE_WINDOWS_LIST[i].draw_width =
DisplayWidth (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_height =
DisplayHeight (display, screen) / 2;
new_server -> SEPERATE_WINDOWS_LIST[i].max_height =
DisplayHeight (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].max_width =
DisplayWidth (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].min_height =
(INT_FHEIGHT * 2);
new_server -> SEPERATE_WINDOWS_LIST[i].min_width = 0;
/*
(INT_FWIDTH * 80);
*/
break;
#if 0
case BUTTON_ps_io:
new_server -> COMMAND_LIST[i].Y_mult = 10;
new_server -> SEPERATE_WINDOWS_LIST[i].Y_mult = (DisplayHeight (display, screen) / INT_FHEIGHT) / 2;
new_server -> SEPERATE_WINDOWS_LIST[i].window_type = DRAWING_WINDOW;
new_server -> SEPERATE_WINDOWS_LIST[i].view_current_sort_widget =
(Widget *) calloc (1, sizeof (Widget));
new_server -> SEPERATE_WINDOWS_LIST[i].menu_bar = 0;
new_server -> SEPERATE_WINDOWS_LIST[i].width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].height =
INT_FHEIGHT * 15;
/*
(FHEIGHT * current_server -> max_slots_in_use) +
(FHEIGHT * 10);
*/
new_server -> SEPERATE_WINDOWS_LIST[i].draw_width =
DisplayWidth (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_height =
DisplayHeight (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].max_height =
DisplayHeight (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].max_width =
DisplayWidth (display, screen);
new_server -> SEPERATE_WINDOWS_LIST[i].min_height =
(INT_FHEIGHT * 2);
new_server -> SEPERATE_WINDOWS_LIST[i].min_width =
(INT_FWIDTH * 80);
break;
#endif
case BUTTON_nfsstat:
new_server -> SEPERATE_WINDOWS_LIST[i].window_type = DRAWING_WINDOW;
new_server -> COMMAND_LIST[i].Y_mult = 25;
new_server -> SEPERATE_WINDOWS_LIST[i].Y_mult = 25;
new_server -> SEPERATE_WINDOWS_LIST[i].width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[i].draw_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].draw_height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[i].max_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].max_width =
(INT_FWIDTH * 80);
new_server -> SEPERATE_WINDOWS_LIST[i].min_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[i].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[i].min_width =
(INT_FWIDTH * 80);
break;
}
}
new_server -> scroll_bar_expose = 0;
new_server -> StatCycle_msec = StatCycle_msecDef;
new_server -> StatPeriod_msec = StatCycle_msecDef;
new_server -> file_count = 0;
new_server -> inode_count = 0;
new_server -> proc_count = 0;
new_server -> region_count = 0;
new_server -> myclist = 0;
new_server -> callout_count = 0;
new_server -> file_max = 0;
new_server -> inode_max = 0;
new_server -> proc_max = 0;
new_server -> region_max = 0;
new_server -> myclist_max = 0;
new_server -> callout_max = 0;
new_server -> cpu_avg_init = 0;
new_server -> wait_avg_init = 0;
/*
* allocate memory for cpu time array averaging buckets
*/
for (i = 0; i < CPU_AVG_MAX; i++)
{
if (!(new_server -> cpu_avg[i] = (time_t *) calloc (5, sizeof (time_t))))
leave_text ("cannot alloc memory for cpu avg arrays", 1);
}
/*
* allocate memory for wait time array averaging buckets
*/
for (i = 0; i < WAIT_AVG_MAX; i++)
{
if (!(new_server -> wait_avg[i] = (time_t *) calloc (3, sizeof (time_t))))
leave_text ("cannot alloc memory for wait avg arrays", 1);
}
new_server -> mynmblock = (int *) calloc (1, sizeof (int));
*new_server -> mynmblock = 1;
new_server -> got_scsi_disk_stats = 0;
new_server -> got_scsi_tape_stats = 0;
new_server -> got_scsi_rom_stats = 0;
new_server -> got_esdi_disk_stats = 0;
new_server -> got_wd_disk_stats = 0;
new_server -> got_cart_tape_stats = 0;
new_server -> got_floppy_disk_stats = 0;
/*
These four variable are initialize in proc.c . This is because
these change constanly.......
*/
new_server -> real_procs = NULL;
new_server -> start_real_procs = NULL;
new_server -> start_my_user = NULL;
new_server -> my_user = NULL;
new_server -> old_my_user = NULL;
new_server -> start_procs = NULL;
new_server -> procs = NULL;
new_server -> oldprocs = NULL;
new_server -> poldprocs = NULL;
new_server -> pprocs = NULL;
new_server -> nprocs = 0;
new_server -> noldprocs = 0;
new_server -> boot_time = 0;
new_server -> heap_memory_pointer = NULL;
new_server -> memory_pointer_bak = NULL;
new_server -> new_memory_state = NULL;
new_server -> memory_state = NULL;
new_server -> procs_alive = 0;
new_server -> old_procs_alive = 0;
new_server -> slots_in_use = 0;
new_server -> old_slots_in_use = 0;
new_server -> max_slots_in_use = 0;
new_server -> old_max_slots_in_use = 0;
new_server -> current_mem_procs = 0;
new_server -> current_mem_procs_bak = 0;
new_server -> num_active_process = 0;
new_server -> got_memory_state = 0;
new_server -> FileDescriptor = 0;
new_server -> connected = 0;
new_server -> nfs_available = 0;
new_server -> must_be_32v5 = 0;
new_server -> cur_device_displayed = 0;
new_server -> max_device_displayed = 0;
new_server -> current_disk_space_entries = 0;
new_server -> max_disk_space_entries = 0;
new_server -> current_disk_space_bak = NULL;
new_server -> current_disk_space_entries_bak = 0;
new_server -> disk_space_screen_mode = 1;
new_server -> show_disk_totals = 1;
new_server -> show_nfs = 1;
new_server -> disk_space_sort_mode = (int *)
calloc (1, sizeof (int) * XtNumber (disk_space_screens));
new_server -> disk_space_sort_order = 1;
new_server -> disk_space_sort_mode[0] = 0;
new_server -> disk_space_sort_mode[1] = 0;
new_server -> disk_space_sort_mode[2] = 0;
new_server -> current_items = 0;
new_server -> user_data_pointer = 0;
new_server -> my_sysinfo = (struct sysinfo *)
calloc (1, sizeof (struct sysinfo));
new_server -> my_sysinfo_last = (struct sysinfo *)
calloc (1, sizeof (struct sysinfo));
new_server -> my_minfo = (struct minfo *)
calloc (1, sizeof (struct minfo));
new_server -> my_minfo_last = (struct minfo *)
calloc (1, sizeof (struct minfo));
new_server -> my_nswap = 0;
new_server -> my_maxmem = (int *) calloc (1, sizeof (int));
new_server -> my_freemem = (int *) calloc (1, sizeof (int));
new_server -> my_availsmem = (int *) calloc (1, sizeof (int));
new_server -> my_v = (struct var *) calloc (1, sizeof (struct var));
new_server -> my_tune = (struct tune *) calloc (1, sizeof (struct tune));
new_server -> my_bootinfo = (struct bootinfo *)
calloc (1, sizeof (struct bootinfo));
new_server -> configuration_string = NULL;
new_server -> mystreams = (struct strstat *)
calloc (1, sizeof (struct strstat));
new_server -> pagest = (struct pagestat *)
calloc (1, sizeof (struct pagestat));
new_server -> rbsize = (ushort *)
calloc (9, sizeof (ushort));
new_server -> Rbsize = (uint *)
calloc (15, sizeof (uint));
new_server -> send_data_count = 0;
new_server -> first_server_read = 0;
new_server -> initial_lwrite = 0;
new_server -> initial_bwrite = 0;
new_server -> initial_lread = 0;
new_server -> initial_bread = 0;
new_server -> cummulative_memory_used = 0;
new_server -> cummulative_swap_used = 0;
new_server -> cummulative_avail_swap = 0;
new_server -> memory_sample_count = 0;
new_server -> ps_procs_to_display = 0;
new_server -> ps_cpu_sort_order = 1;
new_server -> ps_io_sort_order = 1;
new_server -> ps_cpu_time_mode = 1;
new_server -> ps_io_time_mode = 1;
new_server -> ps_sort_mode = 8;
new_server -> ps_display_mode = 12;
new_server -> ps_io_sort_mode = 6;
new_server -> ps_io_display_mode = 8;
new_server -> ps_mem_sort_order = 1;
new_server -> ps_mem_sort_mode = (int *)
calloc (1, sizeof (int) * XtNumber (ps_mem_screens));
new_server -> ps_mem_sort_mode[0] = 6;
new_server -> ps_mem_sort_mode[1] = 7;
new_server -> ps_mem_sort_mode[2] = 2;
new_server -> ps_mem_sort_mode[3] = 2;
new_server -> ps_mem_display_mode = 8;
new_server -> ps_mem_screen_mode = 1;
new_server -> ps_button_change = 0;
new_server -> ps_io_button_change = 0;
new_server -> ps_mem_button_change = 0;
new_server -> PS_MyButton_decl[0].label = "S";
new_server -> PS_MyButton_decl[1].label = "USER";
new_server -> PS_MyButton_decl[2].label = "PID";
new_server -> PS_MyButton_decl[3].label = "CPU";
new_server -> PS_MyButton_decl[4].label = "PRI";
new_server -> PS_MyButton_decl[5].label = "NI";
new_server -> PS_MyButton_decl[6].label = "UCPU";
new_server -> PS_MyButton_decl[7].label = "SCPU";
new_server -> PS_MyButton_decl[8].label = "U+S";
new_server -> PS_MyButton_decl[9].label = "SIZE";
new_server -> PS_MyButton_decl[10].label = "TTY";
new_server -> PS_MyButton_decl[11].label = "CMD";
new_server -> PS_MyButton_decl[12].label = "CUR";
new_server -> PS_MyButton_decl[13].label = "D";
new_server -> PS_MyButton_decl[14].label = "%";
new_server -> IO_PS_MyButton_decl[0].label = "USER";
new_server -> IO_PS_MyButton_decl[1].label = "PID";
new_server -> IO_PS_MyButton_decl[2].label = "SWAP";
new_server -> IO_PS_MyButton_decl[3].label = "CHAR";
new_server -> IO_PS_MyButton_decl[4].label = "READ";
new_server -> IO_PS_MyButton_decl[5].label = "WRITE";
new_server -> IO_PS_MyButton_decl[6].label = "TOTAL";
new_server -> IO_PS_MyButton_decl[7].label = "CMD";
new_server -> IO_PS_MyButton_decl[8].label = "CUR";
new_server -> IO_PS_MyButton_decl[9].label = "D";
new_server -> MEM_PS_MyButton_decl[0].label = "USER";
new_server -> MEM_PS_MyButton_decl[1].label = "PID";
new_server -> MEM_PS_MyButton_decl[2].label = "VSIZE";
new_server -> MEM_PS_MyButton_decl[3].label = "SHRD";
new_server -> MEM_PS_MyButton_decl[4].label = "PRIV";
new_server -> MEM_PS_MyButton_decl[5].label = "WTD";
new_server -> MEM_PS_MyButton_decl[6].label = "TOTAL";
new_server -> MEM_PS_MyButton_decl[7].label = "CMD";
new_server -> MEM_PS_MyButton_decl[8].label = "D";
}
void
set_up_server (char *text, int result)
{
int j, i;
int boot_height = 0;
int new_server_position = 0;
XmString *xmstr;
Arg args[9];
int argcount;
char *server_message = "Connected to server ...";
struct NetworkXswStruct *new_server = NULL;
struct NetworkXswStruct *viewing_server = NULL;
/* Since we have connection, might as well set current_server to this
* new_server . Also, FHEIGHT ,etc reference current_server, and the
* initialize_new_server refernces FHEIGHT, FWIDTH,.......
*/
new_server = insert_server (text);
current_server = new_server;
initialize_new_server (new_server);
new_server -> FileDescriptor = FileDescriptor;
if (result < 0)
new_server -> connected = 0;
else
new_server -> connected = 1;
/*
* We can use xsw_write/xsw_read now that we have initialize the new
* server.....
*/
(void) ftime (&new_server -> timeb_info_read);
xsw_write (new_server,
new_server -> FileDescriptor,
send_os_version_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> os_version,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_user_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> user_data_pointer,
sizeof (int));
new_server -> memory_sample_count = 1;
xsw_write (new_server,
new_server -> FileDescriptor,
send_nfs_available,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> nfs_available,
sizeof (new_server -> nfs_available));
xsw_write (new_server,
new_server -> FileDescriptor,
send_var_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> my_v,
sizeof (struct var));
xsw_write (new_server,
new_server -> FileDescriptor,
send_hz_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> hz,
sizeof (new_server -> hz));
xsw_write (new_server,
new_server -> FileDescriptor,
send_sysinfo_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> my_sysinfo,
sizeof (struct sysinfo));
xsw_write (new_server,
new_server -> FileDescriptor,
send_nswap_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> my_nswap,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_availsmem_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> my_availsmem,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_freemem_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> my_freemem,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_maxmem_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> my_maxmem,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_minfo_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> my_minfo,
sizeof (struct minfo));
xsw_write (new_server,
new_server -> FileDescriptor,
send_tune_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> my_tune,
sizeof (struct tune));
xsw_write (new_server,
new_server -> FileDescriptor,
send_bootinfo_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> my_bootinfo,
sizeof (struct bootinfo));
xsw_write (new_server,
new_server -> FileDescriptor,
send_bootstring_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> bootstring,
sizeof (new_server -> bootstring)
);
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> configuration_string_size,
sizeof (new_server -> configuration_string_size)
);
new_server -> configuration_string = (char *)
calloc (1, new_server -> configuration_string_size);
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> configuration_string,
new_server -> configuration_string_size
);
for (j = 0; j < 1024; j++)
if (new_server -> configuration_string[j] == 10)
boot_height++;
new_server -> SEPERATE_WINDOWS_LIST[BUTTON_tune_var].Y_mult =
11 + new_server -> my_bootinfo -> memavailcnt +
new_server -> my_bootinfo -> memusedcnt + boot_height;
new_server -> SEPERATE_WINDOWS_LIST[BUTTON_tune_var].height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[BUTTON_tune_var].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[BUTTON_tune_var].draw_height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[BUTTON_tune_var].Y_mult;
xsw_write (new_server,
new_server -> FileDescriptor,
send_floppy_disk_available,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> got_floppy_disk_stats,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_scsi_disk_available,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> got_scsi_disk_stats,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_scsi_tape_available,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> got_scsi_tape_stats,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_scsi_rom_available,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> got_scsi_rom_stats,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_esdi_disk_available,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> got_esdi_disk_stats,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_wd_disk_available,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> got_wd_disk_stats,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_cart_tape_available,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> got_cart_tape_stats,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_streams_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> mystreams,
sizeof (struct strstat));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> mynmblock,
sizeof (int));
if ( new_server -> os_version == 1 )
{
new_server -> COMMAND_LIST[BUTTON_streams].Y_mult = 21;
new_server -> SEPERATE_WINDOWS_LIST[BUTTON_streams].Y_mult = 21;
new_server -> SEPERATE_WINDOWS_LIST[BUTTON_streams].height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[BUTTON_streams].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[BUTTON_streams].draw_height =
INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[BUTTON_streams].Y_mult;
new_server -> SEPERATE_WINDOWS_LIST[BUTTON_streams].max_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[BUTTON_streams].Y_mult);
new_server -> SEPERATE_WINDOWS_LIST[BUTTON_streams].min_height =
(INT_FHEIGHT * current_server ->
SEPERATE_WINDOWS_LIST[BUTTON_streams].Y_mult);
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> pagest,
sizeof (struct pagestat));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> Rbsize,
15 * sizeof(uint));
} else
if ( new_server-> os_version == 0 )
{
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> rbsize,
9 * sizeof(ushort));
}
if (new_server -> nfs_available)
{
xsw_write (new_server,
new_server -> FileDescriptor,
send_nfs_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> rcstat,
sizeof (new_server -> rcstat));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> rsstat,
sizeof (new_server -> rsstat));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> clstat,
sizeof (new_server -> clstat));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> svstat,
sizeof (new_server -> svstat));
}
xsw_write (new_server,
new_server -> FileDescriptor,
send_files_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> file_count,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_inodes_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> inode_count,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_procs_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> proc_count,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_regions_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> region_count,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_cblocks_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> myclist,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_call_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> callout_count,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_mount_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> mount_count,
sizeof (int));
xsw_write (new_server,
new_server -> FileDescriptor,
send_disk_space_data,
sizeof (int));
xsw_read (new_server,
new_server -> FileDescriptor,
&new_server -> current_disk_space_entries,
sizeof (int));
new_server ->current_disk_space = (struct disk_space_struct *)
malloc ( new_server -> current_disk_space_entries *
sizeof(struct disk_space_struct));
xsw_read (new_server,
new_server -> FileDescriptor,
new_server -> current_disk_space,
new_server -> current_disk_space_entries *
sizeof(struct disk_space_struct));
new_server -> cummulative_memory_used = *new_server -> my_freemem;
new_server -> cummulative_swap_used = new_server -> my_minfo -> freeswap * NBPSCTR / 1024;
new_server -> cummulative_avail_swap = *new_server -> my_availsmem * NBPP / 1024;
new_server -> memory_sample_count = 1;
new_server -> initial_lwrite = new_server -> my_sysinfo -> lwrite;
new_server -> initial_bwrite = new_server -> my_sysinfo -> bwrite;
new_server -> initial_lread = new_server -> my_sysinfo -> lread;
new_server -> initial_lread = new_server -> my_sysinfo -> bread;
initialize_Proc (new_server);
grok_proc (new_server);
save_last_reading (new_server);
new_server -> timeb_last_info_read = new_server -> timeb_info_read;
(void) memcpy ((char *) new_server -> oldprocs,
(char *) new_server -> procs,
new_server -> slots_in_use *
sizeof (struct my_proc_struct));
new_server -> noldprocs = new_server -> nprocs;
(void) memcpy ((char *) new_server -> poldprocs,
(char *) new_server -> pprocs,
new_server -> noldprocs *
sizeof (struct my_proc_struct *));
set_update_timer (new_server -> StatCycle_msec, new_server);
/*
* Free the server list if it is not NULL, then re-make it according to
* our linked list.....
*/
viewing_server = head_server;
if (server_list != NULL)
XtFree (server_list);
server_list = (XmString *) XtMalloc (sizeof (XmString) * server_count);
for (i = 0; i < server_count; i++)
{
server_list[i] = XmStringCreate (viewing_server -> server_name,
XmSTRING_DEFAULT_CHARSET);
if (viewing_server == new_server)
new_server_position = i;
viewing_server = viewing_server -> forward_link;
}
/*
* Set the list up.... and Select the new server.....
*/
xmstr = (XmString *) XtMalloc (sizeof (XmString) * 1);
xmstr[0] = XmStringCreate (text,
XmSTRING_DEFAULT_CHARSET);
selected_server = new_server;
argcount = 0;
XtSetArg (args[argcount], XmNitems, server_list);
argcount++;
XtSetArg (args[argcount], XmNitemCount, server_count);
argcount++;
XtSetValues (swindow, args, argcount);
XmListDeselectAllItems (swindow);
XmListSelectPos (swindow,
new_server_position + 1, False);
XtFree (xmstr);
/*
* Now set the new server as the current server and update all the fields...
*/
update_StatPeriod (current_server);
update_StatCycle (current_server);
update_Users (current_server);
for (i = 0; i < Max_state_buttons; i++)
{
argcount = 0;
if (current_server -> TOGGLE_BUTTONS_STATE[i] == 1)
XtSetArg (args[argcount], XmNset, True);
else
XtSetArg (args[argcount], XmNset, False);
argcount++;
XtSetValues (TOGGLE_BUTTONS_WIDGETS[i], args, argcount);
}
current_server -> message = server_message;
display_network_msg (current_server, current_server -> message);
}
void
CheckSyncAndSecurity (char *text,
XmSelectionBoxCallbackStruct * client_data,
Widget w)
{
Arg args[9];
int argcount;
int result;
int sync_read;
int dettache_from_server = send_quitting_data;
char server_not_compatible[256];
XmString message;
Widget dialog;
int continue_server = send_continue;
if (!inCommandLineOptionParse)
{
if ((XmSelectionBoxCallbackStruct *) client_data -> reason == XmCR_OK)
XtDestroyWidget (w);
else
{
argcount = 0;
XtSetArg (args[argcount], XmNcursorPosition, strlen (""));
argcount++;
XtSetArg (args[argcount], XmNvalue, "");
argcount++;
XtSetValues (connect_server_text_widget, args, argcount);
}
}
/*
* MUST do read without xsw_read, since we have not created the server
* space yet....
*/
result = read (FileDescriptor,
&sync_read,
sizeof (int));
/*
* See if the server and client are in read/write syncronization and that
* we got a good result back from the read......
*/
if ((sync_read != sync_number) || (result <= 0))
{
/*
* MUST do write without xsw_write, since we have not created the server
* space yet.... Really don't care about the result since we are dettaching
* from the server.....
*/
if (result > 0)
result = write (FileDescriptor,
&dettache_from_server,
sizeof (int));
/*
* close the socket.....
*/
close (FileDescriptor);
if (!inCommandLineOptionParse)
{
sprintf (server_not_compatible, "Server and Client are NOT COMPATIBLE. Server is version %d. Client is version %d", sync_read,
sync_number);
message = XmStringCreateSimple (server_not_compatible);
argcount = 0;
XtSetArg (args[argcount], XmNmessageString, message);
argcount++;
dialog = XmCreateMessageDialog (toplevel, "message", args, argcount);
XmStringFree (message);
XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
XtManageChild (dialog);
}
else
fprintf (stdout, "Server and Client are NOT COMPATIBLE. Server is version %d. Client is version %d-> %s\n", text);
}
else
{
/*
* send our uname so that if security is turned on, the server can see if
* we have privialges to view the system....
*/
result = write (FileDescriptor,
&continue_server,
sizeof (int));
uname (&sysuts);
uname_size = sizeof (struct utsname);
result = write (FileDescriptor,
&uname_size,
sizeof (int));
result = write (FileDescriptor,
&sysuts,
uname_size);
result = read (FileDescriptor,
&got_permission,
sizeof (int));
if (got_permission == CLIENT_NOT_OK)
{
/*
* close the socket.....
*/
close (FileDescriptor);
if (!inCommandLineOptionParse)
{
sprintf (server_not_compatible, "SERVER HAS DENIED CONNECTION!");
message = XmStringCreateSimple (server_not_compatible);
argcount = 0;
XtSetArg (args[argcount], XmNmessageString, message);
argcount++;
dialog = XmCreateMessageDialog (toplevel, "message", args, argcount);
XmStringFree (message);
XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
XtManageChild (dialog);
}
else
fprintf (stdout, "SERVER \"%s\" HAS DENIED CONNECTION!\n", text);
}
else
{
set_up_server (text, result);
if (inCommandLineOptionParse)
GetServerOptions (text, (char *) client_data);
}
}
}
void
read_server (w, client_data, cbs)
Widget w;
caddr_t *client_data;
XmSelectionBoxCallbackStruct *cbs;
{
static int gathering_data_popup_created = 0;
static Widget information_dialog;
XmStringContext context;
XmStringCharSet charset;
XmStringDirection dir;
Boolean seperator;
char *text;
Arg args[9];
int argcount;
XmString message;
Widget dialog;
int result;
char *port_string;
XDefineCursor (XtDisplay (w), XtWindow (w), res.wait_cursor);
XmStringInitContext (&context, cbs -> value);
XmStringGetNextSegment (context, &text, &charset, &dir, &seperator);
GetHost (text);
port_string = XmTextGetString (port_text_widget);
sscanf (port_string, "%d", &configured_port);
XtFree (port_string);
if (get_host_result)
{
if (Connection () == 1)
{
CheckSyncAndSecurity (text, cbs, w);
}
else
{
message = XmStringCreateSimple ("Could NOT CONNECT to server");
argcount = 0;
XtSetArg (args[argcount], XmNmessageString, message);
argcount++;
dialog = XmCreateMessageDialog (toplevel, "message", args, argcount);
XmStringFree (message);
XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
XtManageChild (dialog);
}
}
XmStringFreeContext (context);
XDefineCursor (XtDisplay (w), XtWindow (w), res.cursor);
}
void
disconnect_server ()
{
/*
Widget cancel_button;
*/
Arg args[32];
int argcount;
XmString message;
XmString selection_label = XmStringCreateSimple ("Servers");
Widget dialog;
argcount = 0;
XtSetArg (args[argcount], XmNset, False);
argcount++;
XtSetValues (sub_menu_state_list[BUTTON_disconnect_server], args, argcount);
if (server_count > 0)
{
argcount = 0;
XtSetArg (args[argcount], XmNtitle, "Disconnect Servers");
argcount++;
XtSetArg (args[argcount], XmNlistLabelString, selection_label);
argcount++;
XtSetArg (args[argcount], XmNselectionPolicy, XmMULTIPLE_SELECT);
argcount++;
XtSetArg (args[argcount], XmNscrollingPolicy, XmAUTOMATIC);
argcount++;
XtSetArg (args[argcount], XmNvisibleItemCount, 10);
argcount++;
XtSetArg (args[argcount], XmNvisual, XmVARIABLE);
argcount++;
XtSetArg (args[argcount], XmNlistItems, server_list);
argcount++;
XtSetArg (args[argcount], XmNlistItemCount, server_count);
argcount++;
disconnect_dialog = XmCreateSelectionDialog (toplevel,
"Server Disconnect List",
args, argcount);
XtUnmanageChild (XmSelectionBoxGetChild (disconnect_dialog,
XmDIALOG_HELP_BUTTON));
XtUnmanageChild (XmSelectionBoxGetChild (disconnect_dialog,
XmDIALOG_TEXT));
XtUnmanageChild (XmSelectionBoxGetChild (disconnect_dialog,
XmDIALOG_SELECTION_LABEL));
XtUnmanageChild (XmSelectionBoxGetChild (disconnect_dialog,
XmDIALOG_APPLY_BUTTON));
disconnect_scrolled_list = XmSelectionBoxGetChild (disconnect_dialog,
XmDIALOG_LIST);
argcount = 0;
XtSetArg (args[argcount], XmNselectionPolicy, XmMULTIPLE_SELECT);
argcount++;
XtSetArg (args[argcount], XmNitems, server_list);
argcount++;
XtSetArg (args[argcount], XmNitemCount, server_count);
argcount++;
XtSetValues (disconnect_scrolled_list, args, argcount);
XtAddCallback (disconnect_scrolled_list, XmNmultipleSelectionCallback,
multi_select_disconnect, NULL);
XtAddCallback (disconnect_dialog, XmNcancelCallback,
disconnect_destroy, disconnect_dialog);
XtAddCallback (disconnect_dialog, XmNokCallback,
remove_servers, NULL);
XtManageChild (disconnect_dialog);
}
else
{
message = XmStringCreateSimple ("No servers to disconnect...");
argcount = 0;
XtSetArg (args[argcount], XmNmessageString, message);
argcount++;
dialog = XmCreateMessageDialog (toplevel, "message", args, argcount);
XmStringFree (message);
XtAddCallback (dialog, XmNokCallback, bad_host, NULL);
XtUnmanageChild (XmMessageBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
XtManageChild (dialog);
}
}
void
connect_server ()
{
Widget dialog;
Widget parent_widget;
Widget port_label_widget;
Widget form_widget;
Widget separator_widget;
char port_string[30];
struct servent *ServiceNum;
Arg args[32];
int argcount;
struct utsname sysuts;
XmString prompt = XmStringCreateSimple ("Server to connect to:");
XmString port_prompt = XmStringCreateSimple ("Port:");
XmString default_text;
uname(&sysuts);
default_text = XmStringCreateSimple (sysuts.nodename);
argcount = 0;
XtSetArg (args[argcount], XmNset, False);
argcount++;
XtSetValues (sub_menu_state_list[BUTTON_connect_server], args, argcount);
argcount = 0;
XtSetArg (args[argcount], XmNtitle, "Server?");
argcount++;
XtSetArg (args[argcount], XmNtextString, default_text);
argcount++;
XtSetArg (args[argcount], XmNselectionLabelString, prompt);
argcount++;
XtSetArg (args[argcount], XmNautoUnmanage, False);
argcount++;
dialog = XmCreatePromptDialog (toplevel, "Server?", args, argcount);
XmStringFree (prompt);
XtManageChild (XmSelectionBoxGetChild (dialog, XmDIALOG_APPLY_BUTTON));
connect_server_text_widget = XmSelectionBoxGetChild
(dialog, XmDIALOG_TEXT);
/*
* Create another label and text widget for PORT information....
* Must create a form widget to contain these because the selection box
* widget only allows "1" work area widget to be added......
*/
separator_widget = XmSelectionBoxGetChild (dialog, XmDIALOG_SEPARATOR);
parent_widget = XtParent (connect_server_text_widget);
argcount = 0;
XtSetArg (args[argcount], XmNbottomAttachment, XmATTACH_WIDGET);
argcount++;
XtSetArg (args[argcount], XmNbottomWidget, separator_widget);
argcount++;
form_widget = XmCreateForm (parent_widget, "port_widget", args, argcount);
argcount = 0;
XtSetArg (args[argcount], XmNtopAttachment, XmATTACH_FORM);
argcount++;
port_label_widget = XmCreateLabel (form_widget, "Server port:", args, argcount);
argcount = 0;
XtSetArg (args[argcount], XmNbottomAttachment, XmATTACH_FORM);
argcount++;
XtSetArg (args[argcount], XmNtopAttachment, XmATTACH_WIDGET);
argcount++;
XtSetArg (args[argcount], XmNtopWidget, port_label_widget);
argcount++;
port_text_widget = XmCreateText (form_widget, "port_widget", args, argcount);
if ((ServiceNum = getservbyname (SOCKNAME, PROTOCOL)) == NULL)
sprintf (port_string, "%d", XSWPORT);
else
sprintf (port_string, "%d", ntohs (ServiceNum -> s_port));
argcount = 0;
XtSetArg (args[argcount], XmNcursorPosition, strlen (port_string));
argcount++;
XtSetArg (args[argcount], XmNforeground, colorDisplayMsg.pixel);
argcount++;
XtSetArg (args[argcount], XmNvalue, port_string);
argcount++;
XtSetValues (port_text_widget, args, argcount);
XmTextShowPosition (port_text_widget, strlen (port_string));
XtAddCallback (dialog, XmNokCallback, read_server, NULL);
XtAddCallback (dialog, XmNapplyCallback, read_server, NULL);
XtAddCallback (dialog, XmNcancelCallback, XtDestroyWidget, NULL);
XtUnmanageChild (XmSelectionBoxGetChild (dialog, XmDIALOG_HELP_BUTTON));
XtManageChild (port_label_widget);
XtManageChild (port_text_widget);
XtManageChild (form_widget);
XtManageChild (dialog);
XtPopup (XtParent (dialog), XtGrabNone);
}